#pragma once
#include "UltimatePhysX3Prerequisites.h"
#include "UltimatePhysX3Precompiled.h"
#include "UltimatePhysicsContactListener.h"
#include "UltimatePhysicsActor.h"
#include "PxSimulationEventCallback.h"

//class EntityControl;

class  _UltimatePhysX3Export UltimatePhysX3ContactReport : public PxSimulationEventCallback
{	


	std::vector<UltimatePhysicsContactListener*> listenerList;


	void onContact(const PxContactPairHeader& pairHeader, const PxContactPair* pairs, PxU32 nbPairs)
	{		

		/*for(PxU32 i=0; i < nbPairs; i++)
		{
			const PxContactPair& pair = pairs[i];*/


			UltimatePhysicsActor* actor1 = static_cast<UltimatePhysicsActor*>( pairHeader.actors[0]->userData );	
			UltimatePhysicsActor* actor2 = static_cast<UltimatePhysicsActor*>( pairHeader.actors[1]->userData );

			for(int i=0; i<listenerList.size(); i++)
			{
				listenerList[i]->onContactNotify(actor1,actor2);
			}

		//}

	}

	virtual void  onConstraintBreak (PxConstraintInfo *constraints, PxU32 count)
	{

	}

	virtual void  onWake (PxActor **actors, PxU32 count)
	{

	}

	virtual void  onSleep (PxActor **actors, PxU32 count)
	{

	}

	virtual void  onTrigger (PxTriggerPair *pairs, PxU32 count)
	{

	}


public:

	void addContactListener(UltimatePhysicsContactListener* listener)
	{
		listenerList.push_back(listener);
	}


}PhysX3ContactReport;